import request from '@/utils/request'

export function fetchList(params) {
  return request({
    url: '/admin/merchants',
    method: 'get',
    params: params
  })
}

export function createMerchant(data) {
  return request({
    url: '/admin/merchants',
    method: 'post',
    data: data
  })
}

export function getMerchant(id) {
  return request({
    url: '/admin/merchants/' + id,
    method: 'get'
  })
}

export function updateMerchant(id, data) {
  return request({
    url: '/admin/merchants/' + id,
    method: 'put',
    data: data
  })
}

export function updateStatus(id, data) {
  return request({
    url: '/admin/merchants/' + id,
    method: 'put',
    data: data
  })
}

export function deleteMerchant(id) {
  return request({
    url: '/admin/merchants/' + id,
    method: 'delete'
  })
}

export function createMerchantAdmin(merchantId, data) {
  return request({
    url: '/admin/merchants/' + merchantId + '/admins',
    method: 'post',
    data: data
  })
}

export function recharge(merchantId, data) {
  return request({
    url: '/admin/merchants/' + merchantId + '/recharge',
    method: 'post',
    data: data
  })
}

export function rechargeMerchant(merchantId, data) {
  return recharge(merchantId, data)
}

export function fetchRechargeList(params) {
  return request({
    url: '/admin/recharges',
    method: 'get',
    params: params
  })
}

export function getPermissions(merchantId) {
  return request({
    url: '/admin/merchants/' + merchantId + '/permissions',
    method: 'get'
  })
}

export function updatePermissions(merchantId, data) {
  return request({
    url: '/admin/merchants/' + merchantId + '/permissions',
    method: 'post',
    data: data
  })
}

export function getMenuList() {
  return request({
    url: '/admin/merchants/menu-list',
    method: 'get'
  })
}

export function fetchAdminList(params) {
  return request({
    url: '/admin/merchant-admins',
    method: 'get',
    params: params
  })
}

export function createAdmin(data) {
  return request({
    url: '/admin/merchant-admins',
    method: 'post',
    data: data
  })
}

export function updateAdmin(id, data) {
  return request({
    url: '/admin/merchant-admins/' + id,
    method: 'put',
    data: data
  })
}

export function deleteAdmin(id) {
  return request({
    url: '/admin/merchant-admins/' + id,
    method: 'delete'
  })
}

export function updateAdminStatus(id, data) {
  return request({
    url: '/admin/merchant-admins/' + id + '/status',
    method: 'post',
    data: data
  })
}

export function getAddresses(params) {
  return request({
    url: '/admin/merchants/addresses',
    method: 'get',
    params: params
  })
}
